"use strict";
cc._RF.push(module, '6d4258TaCtOzrk+KzNLrZEr', 'addTiShi');
// Script/addTiShi.ts

"use strict";
/**
 * 增加提示道具
 */
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var GameScene_1 = require("./GameScene");
var gameShareAdsVideo_1 = require("./SdkTools/gameShareAdsVideo");
var PlayData_1 = require("./SdkTools/PlayData");
var storage_1 = require("./SdkTools/storage");
/**
 * 添加提示道具
 */
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var addTiShi = /** @class */ (function (_super) {
    __extends(addTiShi, _super);
    function addTiShi() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.kuang = null;
        // LIFE-CYCLE CALLBACKS:
        _this.issharesucces = false;
        return _this;
        // update (dt) {}
    }
    addTiShi.prototype.onLoad = function () {
        this.showUi();
    };
    addTiShi.prototype.onEnable = function () {
        var _this = this;
        gameShareAdsVideo_1.default.Instance.bannerAds_Show();
        gameShareAdsVideo_1.default.Instance.chaPingAds_Show();
        if (PlayData_1.default.Instance.shareGameGetItem > 0 && cc.sys.platform == cc.sys.WECHAT_GAME) {
            var self = this;
            //@ts-ignore
            window.sharecallback = function () {
                if (PlayData_1.default.Instance.isshare == !0) {
                    console.log('click share');
                    PlayData_1.default.Instance.shareGameGetItem--;
                    PlayData_1.default.Instance.isshare = !1;
                    gameShareAdsVideo_1.default.Instance.showToast('分享成功');
                    _this.addTiShiItem();
                    //@ts-ignore
                    wx.offShow(window.sharecallback);
                }
                else {
                    gameShareAdsVideo_1.default.Instance.showToast('分享失败');
                    //@ts-ignore
                    window.clearTimeout(window.timeid);
                }
            };
            //@ts-ignore
            wx.onShow(window.sharecallback);
            cc.find('kuang/share', this.node).active = !0;
            cc.find('kuang/pb', this.node).active = !1;
        }
        else {
            cc.find('kuang/share', this.node).active = !1;
            cc.find('kuang/pb', this.node).active = !0;
        }
    };
    addTiShi.prototype.onDisable = function () {
        gameShareAdsVideo_1.default.Instance.bannerAds_Hide();
        cc.director.resume();
        if (cc.sys.platform == cc.sys.WECHAT_GAME) {
            //@ts-ignore
            if (window.sharecallback) {
                //@ts-ignore
                wx.offShow(window.sharecallback);
            }
        }
    };
    addTiShi.prototype.showUi = function () {
        this.kuang.scale = 0.3;
        cc.tween(this.kuang)
            .to(0.1, { scale: 1 })
            .call(function () {
            cc.director.pause();
        })
            .start();
    };
    addTiShi.prototype.start = function () {
    };
    addTiShi.prototype.addBtnClick = function () {
        var self = this;
        gameShareAdsVideo_1.default.Instance.motivational_Video_Show(function () {
            self.addTiShiItem();
        }, function () { });
    };
    addTiShi.prototype.addTiShiItem = function () {
        storage_1.default.Instance.setTiShi(storage_1.default.Instance.getTiShi() + 2);
        if (PlayData_1.default.Instance.gameType == PlayData_1.GameType.finddifference_zhaobutong) {
            var sc2 = cc.find('Canvas').getComponent(GameScene_1.default);
            if (sc2) {
                sc2.setTiShi();
            }
        }
        this.closeBtnClick();
    };
    addTiShi.prototype.closeBtnClick = function () {
        this.node.destroy();
    };
    /**
     * 分享
     */
    addTiShi.prototype.shareGame = function () {
        if (cc.sys.platform == cc.sys.WECHAT_GAME) {
            gameShareAdsVideo_1.default.Instance.game_share(function () { });
            PlayData_1.default.Instance.isshare = !1;
            //@ts-ignore
            window.timeid = window.setTimeout(function () {
                PlayData_1.default.Instance.isshare = !0;
            }, 4000);
        }
        else {
            this.closeBtnClick();
        }
    };
    __decorate([
        property(cc.Node)
    ], addTiShi.prototype, "kuang", void 0);
    addTiShi = __decorate([
        ccclass
    ], addTiShi);
    return addTiShi;
}(cc.Component));
exports.default = addTiShi;

cc._RF.pop();